package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.BusinessSystemRoleEntity;
import com.jinmdz.fmis.mapper.mapper.provider.BusinessSystemRoleProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 业务系统角色Mapper
 *
 * @author generator
 * @date 2020-03-18 15:10
 */
public interface BusinessSystemRoleMapper {

    /**
     * 增加BusinessSystemRole
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-18 15:10
     */
    @InsertProvider(type = BusinessSystemRoleProvider.class, method = "insertBusinessSystemRole")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertBusinessSystemRole(@Param("entity") BusinessSystemRoleEntity entity);

    /**
     * 删除BusinessSystemRole
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-18 15:10
     */
    @Update(" update business_system_role set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForBusinessSystemRole(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改BusinessSystemRole
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-18 15:10
     */
    @UpdateProvider(type = BusinessSystemRoleProvider.class, method = "updateBusinessSystemRole")
    void updateBusinessSystemRole(@Param("entity") BusinessSystemRoleEntity entity);

    /**
     * 查询BusinessSystemRole实体
     *
     * @param id 主键
     * @return BusinessSystemRoleEntity
     * @author generator
     * @date 2020-03-18 15:10
     */
    @Select(" select id,deleted,business_system_id,role_code,role_name,role_type_code,disable_state,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from business_system_role where id = #{id} and deleted = 0 limit 1 ")
    BusinessSystemRoleEntity getBusinessSystemRoleById(@Param("id") Integer id);

    /**
     * 查询BusinessSystemRole列表
     *
     * @param entity 数据实体
     * @return BusinessSystemRoleEntity
     * @author generator
     * @date 2020-03-18 15:10
     */
    @SelectProvider(type = BusinessSystemRoleProvider.class, method = "listBusinessSystemRole")
    ArrayList<BusinessSystemRoleEntity> listBusinessSystemRole(@Param("entity") BusinessSystemRoleEntity entity);
}